package com.ruoyi.canteen.service.impl;

import java.util.List;

import com.ruoyi.canteen.vo.CanteenOrderAddressVo;
import com.ruoyi.common.utils.DateUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.canteen.mapper.CanteenOrderAddressMapper;
import com.ruoyi.canteen.domain.CanteenOrderAddress;
import com.ruoyi.canteen.service.ICanteenOrderAddressService;

/**
 * 订餐地址Service业务层处理
 * 
 * @author zhangw
 * @date 2021-09-19
 */
@Service
public class CanteenOrderAddressServiceImpl implements ICanteenOrderAddressService 
{
    @Autowired
    private CanteenOrderAddressMapper canteenOrderAddressMapper;

    /**
     * 查询订餐地址
     * 
     * @param id 订餐地址主键
     * @return 订餐地址
     */
    @Override
    public CanteenOrderAddress selectCanteenOrderAddressById(Long id)
    {
        return canteenOrderAddressMapper.selectCanteenOrderAddressById(id);
    }

    /**
     * 查询订餐地址列表
     * 
     * @param canteenOrderAddress 订餐地址
     * @return 订餐地址
     */
    @Override
    public List<CanteenOrderAddress> selectCanteenOrderAddressList(CanteenOrderAddress canteenOrderAddress)
    {
        return canteenOrderAddressMapper.selectCanteenOrderAddressList(canteenOrderAddress);
    }

    /**
     * 新增订餐地址
     * 
     * @param canteenOrderAddress 订餐地址
     * @return 结果
     */
    @Override
    public int insertCanteenOrderAddress(CanteenOrderAddress canteenOrderAddress)
    {
        canteenOrderAddress.setCreateTime(DateUtils.getNowDate());
        return canteenOrderAddressMapper.insertCanteenOrderAddress(canteenOrderAddress);
    }

    /**
     * 修改订餐地址
     * 
     * @param canteenOrderAddress 订餐地址
     * @return 结果
     */
    @Override
    public int updateCanteenOrderAddress(CanteenOrderAddress canteenOrderAddress)
    {
        return canteenOrderAddressMapper.updateCanteenOrderAddress(canteenOrderAddress);
    }

    /**
     * 批量删除订餐地址
     * 
     * @param ids 需要删除的订餐地址主键
     * @return 结果
     */
    @Override
    public int deleteCanteenOrderAddressByIds(Long[] ids)
    {
        return canteenOrderAddressMapper.deleteCanteenOrderAddressByIds(ids);
    }

    /**
     * 删除订餐地址信息
     * 
     * @param id 订餐地址主键
     * @return 结果
     */
    @Override
    public int deleteCanteenOrderAddressById(Long id)
    {
        return canteenOrderAddressMapper.deleteCanteenOrderAddressById(id);
    }

    /**
     * 作废订餐地址
     *
     * @param id 订餐地址主键
     * @param userId 作废操作人ID
     * @return 结果
     */
    @Override
    public int invalidCanteenOrderAddressById(Long id, Long userId){
        return canteenOrderAddressMapper.invalidCanteenOrderAddressById(id, userId);
    }

    /**
     * 设置默认订餐地址
     * @param id 订餐地址主键
     * @param userId 作废操作人ID
     * @return 结果
     */
    @Override
    public int setDefaultCanteenOrderAddress(@Param("id") Long id, @Param("userId") Long userId){
        return canteenOrderAddressMapper.setDefaultCanteenOrderAddress(id, userId);
    }

    /**
     * 查询订餐地址列表
     *
     * @param userId 用户id
     * @return 订餐地址集合
     */
    @Override
    public List<CanteenOrderAddressVo> selectCanteenOrderAddressListByUserId(Long userId, Integer isDefault){
        return canteenOrderAddressMapper.selectCanteenOrderAddressListByUserId(userId, isDefault);
    }
}
